﻿@using LanDBom.Models;
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Genertals.cshtml";
}

<from>
    <fieldset class="boun">
        <legend></legend>
        <div class="row bian">
            <label class="col-sm-3 breadcrumb-item active">步骤三：BOM工艺添加</label>
            <ul id="lisul" class="row col-sm-5">
                <li class="lisu"></li>&rArr;
                <li class="lisu"></li>&rArr;
                <li class="lisu">3</li>&rArr;
                <li class="lisu"></li>&rArr;
                <li class="lisu"></li>
            </ul>
        </div>
    </fieldset>
</from>
<div>
    <from>
        <fieldset class="boun">
            <legend class="len1">申请单信息</legend>
            <table class="table" id="BiaoTo">
                @foreach (var item in ViewBag.F_kehu as List<Applications>)
                {
                    <tr>
                        <td>
                            @Html.Label("客户名称:") @item.App_Kehu
                        </td>
                        <td>
                            @Html.Label("申请编号:")<label id="shenDan">@item.AP_bian</label>
                        </td>
                    </tr>
                    <tr>
                        <td>@Html.Label("项目名称:") @item.APP_name</td>
                        <td>@Html.Label("终端客户:") @item.APP_Zhong</td>
                    </tr>
                    <tr>
                        <td>@Html.Label("发布日期:") @item.App_qishi</td>
                        <td>@Html.Label("截止日期:")@item.App_JTime</td>
                    </tr>
                    <tr>
                        <td>@Html.Label("收货地址:") @item.App_dizhi</td>
                        <td>@Html.Label("产品应用:") @item.App_lei</td>
                    </tr>
                    <tr>
                        <td>@Html.Label("收款方式:") @item.App_sho</td>
                        <td>@Html.Label("是否设计:")<lable id="Shenji">@item.APP_she</lable></td>
                    </tr>
                }
            </table>
        </fieldset>
    </from>
</div>
<div>
    <from class="row padtop col-12 biao1">
        <fieldset class="boun">
            <legend class="len1">BOM信息</legend>
            <div class="row houn">
                <p class="col-sm-3">@Html.Label("客户料号/料号:")  @Html.TextBox("liao")</p>
                <p class="col-sm-3">@Html.Label("物料名称"):@Html.TextBox("shu")</p>
                <p class="col-sm-2"><input type="button" id="BomS" value="查询" class="btn btn-info btn-outline-secondary" /></p>
                @*<p class="col-sm-2"><input type="button" id="Quebecs" value="确定" class="btn" /></p>*@
            </div>
        </fieldset>
    </from>
    <table class="table table-sm gun tab">
        <thead class="thead-light" id="BoCt">
            <tr style="text-align-last:center;">
                <th scope="col"><input type="checkbox" /></th>
                <th scope="col">编号</th>
                <th scope="col">层次</th>
                <th scope="col">终端客户料号</th>
                <th scope="col">料号</th>
                <th scope="col">物料名称</th>
                <th scope="col">预计年用量</th>
                <th scope="col">BOM用量</th>
                <th scope="col">是否需要参与询价</th>
                <th scope="col">添加工艺</th>
            </tr>
        </thead>
        <tbody data-spy="scroll" id="BoTa" class="thead-light" style="height:400px;">
            @foreach (var item in ViewBag.F_bom as List<BOMini>)
            {
                <tr style="text-align-last:center;">
                    <td><input type="checkbox" /></td>
                    <td></td>
                    <td id="CG_INFSQD" style="display:none">@item.BOM2_id</td>
                    <td id="chen"> @item.BOM2_chen</td>
                    <td id="duan"> @item.BOM2_duan</td>
                    <td id="liao"> @item.BOM2_liao</td>
                    <td id="wuliao"> @item.BOM2_wuLiu</td>
                    <td> @item.BOM2_Nian</td>
                    <td> @item.BOM2_Yong</td>
                    <td><input type="checkbox" name="Jingoyng" value="禁用" /></td>
                    <td id="DanJe" style="color:darkblue;">添加工艺</td>
                </tr>
            }
        </tbody>
    </table>
    <p class="col-sm-2"><input type="button" id="Quebecs" value="生成报价单" class="btn btn-outline-secondary" /></p>
</div>
@*隐藏工艺选项 工艺选项--模切，彩印 印刷 木箱加工 标签类型 是否提供资料 *@
<div style="display:none" class="Dyang" id="DyangSE">

    <form class=" padtop biao1">
        <fieldset class="boun" style="width:100%;">
            <legend class="len1">添加工艺</legend>
            <table id="Gong" border="0">
                @*包含彩印*@
                <tr style="display: none" title="纸质" id="ZIzhi">
                    <td><p>*印刷:</p></td>
                    <td>
                        <select name="firsts">
                            <option>无</option>
                            @foreach (var item in ViewBag.Yinshua as List<libray>)
                            {
                                <option value="@item.LB_fne">@item.LB_fne</option>
                            }
                        </select>
                    </td>
                    <td><p>*是否需要模切(默认无)</p></td>
                    <td><input type="number" name="Moqie" min="0" max="10">刀</td>
                    <td></td>
                    <td></td>
                </tr>
                @*选择印色*@
                <tr id="YinseWU" style="display:none">
                    <td></td>
                    <td>印色一：<input type="text" name="One" value="" /></td>
                    <td>印色二：<input type="text" name="Two" value="" /></td>
                    <td>印色三：<input type="text" name="Three" value="" /></td>
                    <td>印色四：<input type="text" name="four" value="" /></td>
                    <td>印色五：<input type="text" name="Five" value="" /></td>
                </tr>
                <tr style="display:none" title="木质" id="MUzhi">
                    <td><p>*熏蒸(包角)</p></td>
                    <td><input type="radio" name="Baolan" value="否">否</td>
                    <td><input type="radio" name="Baolan" value="是">是</td>
                    <td></td>
                    @*使用多选框将选项放入输入框*@
                    <td colspan="2">
                    </td>
                </tr>
                <tr title="通用">
                    <td><p>*是否提供资料</p></td>
                    <td><input type="checkbox" name="Tuzhi1" value="客户图纸" onclick="KH_tu()">客户图纸</td>
                    <td><input type="checkbox" name="Tuzhi2" value="印刷图" onclick="Yin_tu()">印刷图</td>
                    <td><input type="checkbox" name="Tuzhi3" value="模切图" onclick="MO_tu()">模切图</td>
                    <td><input type="checkbox" name="Tuzhi4" value="样品">样品</td>
                    <td>其他<input type="text" name="Ziqie"></td>
                </tr>
                <tr id="Tushunfe">
                    <td colspan="2">
                        <p>客户图纸：</p>
                        <div class="input-group mb-3">
                            <div class="input-group-prepend">
                                <input type="button" class="input-group-text" id="exampleFormControlFile1" value="选择文件" disabled />
                            </div>
                            <input type="text" id="textfield" placeholder="Username" readonly>
                        </div>
                    </td>
                    <td colspan="2">
                        <p>印刷图：</p>
                        <div class="input-group mb-3">
                            <div class="input-group-prepend">
                                <input type="button" class="input-group-text" id="exampleFormControlFile2" value="选择文件" disabled />
                            </div>
                            <input type="text" id="textfielded" placeholder="Username" readonly>
                        </div>
                    </td>
                    <td colspan="2">
                        <p>模切图：</p>
                        <div class="input-group mb-3">
                            <div class="input-group-prepend">
                                <input type="button" class="input-group-text " id="exampleFormControlFile3" value="选择文件" disabled />
                            </div>
                            <input type="text" id="textfieldsd" placeholder="Username" readonly>
                        </div>
                    </td>
                </tr>
                <tr title="纸质" id="Zhizhi" style="display:none">
                    <td><p>*模具</p></td>
                    <td><input type="radio" name="Muju" value="无" checked="checked">无</td>
                    <td><input type="radio" name="Muju" value="有">有</td>
                    <td>
                        模具类型:<select name="Mujus" disabled>
                            <option>无</option>
                            @foreach (var item in ViewBag.mujus as List<libray>)
                            {
                                <option value="@item.LB_fne">@item.LB_fne</option>
                            }
                        </select>
                    </td>
                    <td><p>*是否提供模具</p></td>
                    <td>
                        <input type="radio" name="Tigong" value="否" checked="" />否
                        <input type="radio" name="Tigong" value="是" />是
                    </td>
                </tr>
                <tr title="通用">
                    <td><p>*物理要求</p></td>
                    <td><input type="radio" name="naiya" value="无" checked="checked">无</td>
                    <td><input type="radio" name="naiya" value="有">有</td>
                    <td>抗压（KG）<input type="text" name="YA" readonly></td>
                    <td>耐破（Kpa）<input type="text" name="NP" readonly></td>
                    <td>边压(N/m)<input type="text" name="BY" readonly></td>
                </tr>
                <tr title="木质和纸质通用" id="MZtong" style="display:none">
                    <td><p>*结合</p></td>
                    <td>
                        <select name="JieHes">
                            <option>无</option>
                            @foreach (var item in ViewBag.jieshe as List<libray>)
                            {
                                <option value="@item.LB_fne">@item.LB_fne</option>
                            }
                        </select>
                    </td>
                    <td colspan="2">
                        <p>*表面处理&nbsp;<input type="text" name="Biaomian" value="" readonly style="width:200px;" /></p>
                        <div style="display:none" id="Yinchangs" class="Dingdiv">
                            <input type="button" id="BiaQ" value="确定" class="btn-sm" />
                            <input type="button" id="QingQ" value="清空" class="btn-sm" />
                            <ul>
                                @foreach (var item in ViewBag.Biaomian as List<libray>)
                                {
                                    <li><input type="checkbox" value="@item.LB_fne" />@item.LB_fne</li>
                                }
                            </ul>
                        </div>
                    </td>
                    <td><input type="checkbox"></td>
                    <td><input type="checkbox"></td>
                </tr>
                <tr title="塑料" id="ShuL" style="display:none">
                    <td colspan="2">
                        <p>*塑料&nbsp;<input type="text" name="Shuliao" value="" readonly style="width:200px;" /></p>
                        <div style="display:none" id="Yinchangsed" class="Dingdiv">
                            <input type="button" id="BiaQ1" value="确定" class="btn-sm" />
                            <input type="button" id="QingQ1" value="清空" class="btn-sm" />
                            <ul>
                                @foreach (var item in ViewBag.XIshu as List<libray>)
                                {
                                    <li><input type="checkbox" value="@item.LB_fne" />@item.LB_fne</li>
                                }
                            </ul>
                        </div>
                    </td>
                    <td><input type="checkbox"></td>
                    <td><input type="checkbox"></td>
                    <td><input type="checkbox"></td>
                    <td><input type="checkbox"></td>
                </tr>
                @*  <tr>
                        <td><p></p></td>
                        <td><input type="checkbox"></td>
                        <td><input type="checkbox"></td>
                        <td><input type="checkbox"></td>
                        <td><input type="checkbox"></td>
                        <td><input type="checkbox"></td>
                    </tr>*@
            </table>
        </fieldset>
    </form>
    <button id="Tui" class="btn btn-link">退出</button>
    <button id="Quebec" class="btn btn-link">确定</button>
</div>
<div style="display:none;overflow:auto;height:360px;" id="木质" class="jsmb">
    <table>
        <tr>
            <td>长</td>
            <td><input type="number" id="MZ_C" /></td>
            <td>宽</td>
            <td><input type="number" id="MZ_K" /></td>
            <td>高</td>
            <td><input type="number" id="MZ_G" /></td>
        </tr>
    </table>
    <table>
        <thead>
            <tr>
                <th colspan="12">
                    木材费
                </th>
            </tr>
            <tr>
                <th rowspan="2">序号</th>
                <th rowspan="2">品名</th>
                <th rowspan="2">材料类别</th>
                <th colspan="4">线板尺寸</th>
                <th rowspan="2">数量</th>
                <th rowspan="2">m³</th>
                <th rowspan="2">损耗</th>
                <th>材料含税单价</th>
                <th>材料费</th>
            </tr>
            <tr>
                <th>长</th>
                <th>宽</th>
                <th>厚</th>
                <th>实际厚度</th>
                <th>RMB/m3</th>
                <th>RMB/pcs</th>
            </tr>
        </thead>
        <tbody id="MZ_MCF">
            <tr>
                <td></td>
                <td><input type="text" style="width:60px;height:25px" /></td>
                <td>
                    <select class="MZ_CL" style="width:60px;height:25px" id="MZ_CL">
                        <option>请选择材料</option>
                        @foreach (var item in ViewBag.parice as List<parice>)
                        {
                            if (item.PA_Shuxing == 1)
                            {
                                <option value="@item.PA_ZhongL">@item.PA_ZhongL</option>
                            }

                        }
                    </select>
                </td>
                <td><input type="number" class="MZ_gg" style="width:60px;height:25px" /></td>
                <td><input type="number" class="MZ_gg" style="width:60px;height:25px" /></td>
                <td><input type="number" class="MZ_gg" style="width:60px;height:25px" /></td>
                <td><input type="number" class="MZ_gg" style="width:60px;height:25px" /></td>
                <td><input type="number" class="MZ_gg" style="width:60px;height:25px" /></td>
                <td class="MZ_TJ"></td>
                <td></td>
                <td></td>
                <td class="MZ_MCF"></td>
                <td><a href="#" id="MZ_CZ">添加</a></td>
            </tr>
        </tbody>
        <tfoot>
            <tr>
                <th>合计</th>
                <th colspan="7"></th>
                <th id="ALL_MCTJ"></th>
                <th colspan="2"></th>
                <th id="ALL_MCF"></th>
            </tr>
        </tfoot>
    </table>
    <hr />
    <table style="text-align:center">
        <thead>
            <tr>
                <th colspan="12">
                    辅料费
                </th>
            </tr>
            <tr>
                <th>序号</th>
                <th>名称</th>
                <th>数量</th>
                <th>材料含税单价</th>
                <th>材料费</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody id="MZ_MCF">
            <tr>
                <td></td>
                <td>
                    <select style="width:60px;height:25px" id="MZ_FL">
                        <option>请选择材料</option>
                        @foreach (var item in ViewBag.parice as List<parice>)
                        {
                            if (item.PA_Shuxing == 6)
                            {
                                <option value="@item.PA_T">@item.PA_ZhongL</option>
                            }

                        }
                    </select>
                </td>
                <td><input type="number" style="width:60px;height:25px" id="MZ_FLSL" /></td>
                <td></td>
                <td class="MZ_FLF"></td>
                <td><a href="#" id="MZ_FLH">添加</a></td>
            </tr>
        </tbody>
        <tfoot>
            <tr>
                <th>合计</th>
                <th colspan="3"></th>
                <th id="ALL_FLF"></th>
            </tr>
        </tfoot>
    </table>
    <hr />
    <table style="text-align:center">
        <thead>
            <tr>
                <th colspan="2">
                    加工费
                </th>
            </tr>
            <tr>
                <th>工序</th>
                <th>费用</th>
                <th>操作</th>
            </tr>
            <tr>
                <td>
                    <select style="width:60px;height:25px" id="MZ_RG">
                        <option value=0>请选择</option>
                        @foreach (var item in ViewBag.ListZBxx as List<libray>)
                        {
                            if (item.ST_ID == 7)
                            {
                                <option value="@item.LB_jia">@item.LB_fne</option>
                            }

                        }
                    </select>
                </td>
                <td id="MZ_RGF"></td>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td><input type="text" style="width:60px;height:25px" /></td>
                <td><input type="number" class="MZ_jgf" style="width:60px;height:25px" /></td>
                <td><a href="#" id="MZ_JGFH">添加</a></td>
            </tr>
        </tbody>
        <tfoot>
            <tr>
                <th>合计</th>
                <th id="ALL_jgf"></th>
            </tr>
        </tfoot>
    </table>
    <hr />
    <table>
        <thead>
            <tr>
                <th colspan="2">
                    运输费
                </th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>运输费</td>
                <td><input type="number" id="MZ_YSF" class="MZ_YS" /></td>
            </tr>
            <tr>
                <td>装车数量</td>
                <td><input type="number" id="MZ_ZCSL" class="MZ_YS" /></td>
            </tr>
            <tr>
                <td>运输费小计</td>
                <td id="MZ_YSFXJ"></td>
            </tr>
        </tbody>
    </table>
    <table>
        <thead>
            <tr>
                <th colspan="2">
                    热处理费用
                </th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>运输费</td>
                <td><input type="number" id="MZ_YSF" class="MZ_YS" /></td>
            </tr>
            <tr>
                <td>装车数量</td>
                <td><input type="number" id="MZ_ZCSL" class="MZ_YS" /></td>
            </tr>
            <tr>
                <td>运输费小计</td>
                <td id="MZ_YSFXJ"></td>
            </tr>
        </tbody>
    </table>
    <hr />
</div>
@section scripts{
    <script src="~/Scripts/jquery-3.4.1.min.js"></script>
    <script src="~/Scripts/bootstrap.min.js"></script>
    <script>
        $(function () {
            if ($("#Shenji").text() == "Y") {
                $('input[name="Sheji"]').removeAttr('disabled')
            }
            $("#BoTa tr td").addClass("inwei");
            $("#textfieldsd,#textfielded,#textfield").css("width", "120px")
            $("#Gong tr td p").addClass("tbtr1");
            $("#Gong tr td input:text").addClass("Shu1");
            $("#BiaoTo tr td").css("padding", "0.1rem", "padding-left", "0.3rem");
            $("#Gong tbody tr").css("border-bottom", "1px solid rgb(255 80 105 / 73%)");
            $("#YinseWU td input:text").hide();
            $("#Gong tbody tr td:first").css("width", "70px;");
            var len = $("#BoTa tr").length;
            for (var i = 0; i < len; i++) {
                $("#BoTa tr:eq(" + i + ") td:nth-child(1)").text(i + 1);
            }
            $("#Tushunfe").find("input[type='button']").css("width", "85px")
        })
        function KH_tu() {
            if ($("#exampleFormControlFile1").is(":disabled") == true) {
                $("#exampleFormControlFile1").removeAttr('disabled');
            } else {
                $("#exampleFormControlFile1").prop('disabled', true);
            }
        }
        function Yin_tu() {
            if ($("#exampleFormControlFile2").is(":disabled") == true) {
                $("#exampleFormControlFile2").removeAttr('disabled');
            } else {
                $("#exampleFormControlFile2").prop('disabled', true);
            }

        }
        function MO_tu() {
            if ($("#exampleFormControlFile3").is(":disabled") == true) {
                $("#exampleFormControlFile3").removeAttr('disabled');
            } else {
                $("#exampleFormControlFile3").prop('disabled', true);
            }
        }
        //添加工艺部分
        $(function () {
            $(document).on("click", "#DanJe", function (e) {
                //关联数据库 获取主键的值
                var Intid = $(e.target).prev().prev().prev().prev().prev().prev().prev().prev().text()
                $("#DyangSE").css("display", "block");
                //退出按钮
                $("#Tui").click(function () {
                    $("#DyangSE").css("display", "none");
                })
                //隐藏印刷颜色输入
                $('select[name="firsts"]').click(function () {
                    var ioun = $('select[name="firsts"] option:selected').val();
                    console.log(ioun)
                    if (ioun != "无") {
                        $("#YinseWU td input:text").show();
                    } else {
                        $("#YinseWU td input:text").hide();
                    }
                });
                //模具禁用
                $('input:radio[name="Muju"]').click(function () {
                    var Ajisn = $("input:radio[name='Muju']:checked").val()
                    console.log(Ajisn)
                    if (Ajisn != "无") {
                        $('select[name = "Mujus"]').prop('disabled', false)
                    } else {
                        $('select[name = "Mujus"]').prop('disabled', true)
                    }
                })
                //物理要求
                $('input:radio[name="naiya"]').click(function () {
                    var ioun = $('input:radio[name="naiya"]:checked').val();
                    if (ioun == "有") {
                        $('input[name="YA"],input[name="NP"],input[name="BY"]').removeAttr("readonly");
                    } else {
                        $('input[name="YA"],input[name="NP"],input[name="BY"]').attr("readonly", "readonly");
                    }
                })
                //判断启用
                $.ajax({
                    url: '/Material/Index',
                    type: 'POST',
                    data: { "BOM2_id": Intid, "state": 4 },
                    success: function (shune) {
                        alert(shune)
                        switch (shune) {
                            case 1:
                                $(".jsmb").css("display", "block");
                                $("#DyangSE").css("display", "none");
                                break;
                            case 2:
                                $("").show();
                                break;
                            case 3:
                                $("#ShuL").show();
                                $("#MUzhi,#MZtong,#ZIzhi,#YinseWU,#Zhizhi").hide();
                                break;
                            case 4:
                                $("").show();
                                break;
                            case 5:
                                $("#ZIzhi,#MZtong,#YinseWU,#Zhizhi").show();
                                $("#MUzhi,#ShuL").hide();
                                break;
                            default:
                                alert("类型不明确！")
                                break;
                        }
                    }, error: function (e) {
                        alert(e)
                    }
                })
                /*function creataTab(shune) {
                    //遍历
                    $.each(shune, function (i, item) {
                        var biaoshi = "Go" + item.LB_ID
                        var $tr = (`<tr>
                        <td>${item.LB_fne}</td>
                        <td><input type="radio" name="${biaoshi}" value="">无</td>
                        <td><input type="radio" name="${biaoshi}" value="${item.LB_fne}">有</td>
                        <td style="display:none"><lable id="${biaoshi}">${item.LB_jia}</lable></td>
                        </tr>`);
                        if (item.LB_fne == "印刷") {
                            var Yin = Yin + item.LB_ID
                            $tr = (`<tr>
                        <td>${item.LB_fne}</td>
                        <td><input type="radio" name="${biaoshi}" value="">无</td>
                        <td><input type="radio" name="${biaoshi}" value="${item.LB_fne}">有</td>
                        <td><input type="text" name="${Yin}"></td>
                        <td style="display:none"><lable id="${biaoshi}">${item.LB_jia}</lable></td>
                        </tr>`);
                        }
                        $("#Gongyi").append($tr);
                    })
                }*/

                //点击确定按钮  获取选中的工艺名
                $("#Quebec").click(function () {
                    var Yinshua;//判断是否印刷
                    var YinSe//保存印色
                    var yin = $('select[name="firsts"] option:selected').val();//获取印刷选择
                    if (yin == "无") {
                        Yinshua = "无";
                    } else {
                        Yinshua = yin;
                        var one = $('input[name="One"]').val();
                        var two = $('input[name="Two"]').val();
                        var three = $('input[name="Three"]').val();
                        var four = $('input[name="four"]').val();
                        var five = $('input[name="Five"]').val();
                        YinSe = one + ";" + two + ";" + three + ";" + four + ";" + five;
                    }
                    //获取模切数据
                    var mu = $('input[name="Moqie"]').val();
                    //获取木箱包角数据
                    var muxinag = $('input:radio[name="Baolan"]:checked').val();
                    //获取表面处理数据
                    var biaomina = $('input[name="Biaomian"]').val();
                    //获取提供资料数据
                    var kehu = $("input[name='Tuzhi1']:checked").val();
                    var shua = $("input[name='Tuzhi2']:checked").val();
                    var muo = $("input[name='Tuzhi3']:checked").val();
                    var ping = $("input[name='Tuzhi4']:checked").val();
                    var qita = $("input [name='Ziqie']").text();
                    var ke = kehu + ";" + shua + ";" + muo + ";" + ping + ";" + qita;
                    //是否需要模具  是否提供模具 模具类型
                    var xuyao = $('select[name="Mujus"] option:selected').val()
                    var tigong = $("input:radio[name='Tigong']:checked").val()
                    //物理要求
                    var wuli = $("input:radio[name='naiya']:checked").val();
                    if (wuli == "有") {
                        var nai = $("input[name='YA']").val();
                        var neipo = $("input[name='NP']").val();
                        var bian = $("input[name='BY']").val();
                        wuli = "有" + ";" + nai + ";" + neipo + ";" + bian;
                    }
                    //塑料
                    var shunji = $('input[name="Shuliao"]').val()
                    //获取上传文件的地址
                    var hehuwenjain = $("#textfield").val();
                    var yinshajain = $("#textfielded").val();
                    var muquewenjain = $("#textfieldsd").val();
                    var tuozhi = hehuwenjain + ";" + yinshajain + ";" + muquewenjain;

                    var operati = {
                        OP_Yin: Yinshua,
                        OP_YinSe: YinSe,
                        OP_Muqie: mu,
                        OP_Muxinag: muxinag,
                        OP_biao: biaomina,
                        OP_Mujiu: xuyao,
                        OP_Tigong: tigong,
                        OP_Wuli: wuli,
                        OP_shu: shunji,
                        OP_ZiL: ke,
                        OP_jiehe: $('select[name="JieHes"] option:selected').val()
                    }
                    var design = {
                        De_dizhi: tuozhi
                    }
                    console.log(operati + design);
                    $.ajax({
                        url: "/Material/Addoperati",
                        type: "POST",
                        data: { "operat": operati, "design": design, "BOM2_id": Intid },
                        success: function (s) {
                            alert(s);
                            $("#DyangSE").css("display", "none");
                            location.reload(true);
                        },
                        error: function (s) {
                            alert("系统错误!");
                        }
                    })
                })

            })
        })

        //查找功能
        $(function () {
            $("#BomS").click(function () {
                var liao = $("#liao").val();
                var wu = $("#shu").val();
                var hu = $("#shenDan").text();
                $.ajax({
                    url: '/Cuobaojia/Index',
                    type: 'POST',
                    data: { "BOM2_wuLiu": wu, "BOM2_liao": liao, "names": hu, "state": 1 },
                    success: function (e) {
                        createRow(e);
                    },
                    error: function () {
                        alert("系统错误");
                    }
                })
                function createRow(e) {
                    $("#BoTa tr").remove();
                    $.each(e, function (i, item) {
                        var $tr = $(`<tr style="text-align-last:center;">
                                           <td></td>
                                                <td id="CG_INFSQD" style="display:none">${item.BOM2_id}</td>
                                                <td id="chen"> ${item.BOM2_chen}</td>
                                                <td id="duan">${item.BOM2_duan}</td>
                                                <td id="liao"> ${item.BOM2_liao}</td>
                                                <td id="wuliao"> ${item.BOM2_wuLiu}</td>
                                                <td> ${item.BOM2_Nian}</td>
                                                <td> ${item.BOM2_Yong}</td>
                                                <td><input type="checkbox" name="Danji" value="禁用" /></td>
                                                <td id="DanJe" style="color:darkblue;">添加工艺</td>
                    <td style="display:none"> ${item.BOM2_BQing}</td>
                                        </tr > `);
                        $("#BoTa").append($tr);
                    })
                    var len = $("#BoTa tr").length;
                    for (var i = 0; i < len; i++) {
                        $("#BoTa tr:eq(" + i + ") td:nth-child(1)").text(i + 1);
                    }
                }
            })
        })
        //确定功能--提交进入下一页
        $(function () {

            $("#Quebecs").click(function () {
                var hu = $("#shenDan").text();
                $.ajax({
                    url: '/Cuobaojia/Index',
                    type: 'POST',
                    data: { "Ap_bian": hu, "state": 2 },
                    success: function (e) {
                        if (e == "修改失败") {
                            alert(e);
                        } else if (e == "修改成功") {
                            xiugai()
                            window.location.href = "/Cuobaojia/BomsView?names=" + hu;
                        }
                    },
                    error: function () {
                        alert("系统有误！");
                    }
                })
                function xiugai() {
                    var BOMinise = []
                    $("#BoTa tr").each(function (index, obj) {
                        BOMinise.push({
                            BOM2_id: $("#CG_INFSQD", obj).text(),
                            BOM2_zhuang: $("input[name='Jingoyng']:checked", obj).val()
                        })
                    })
                    console.log(BOMinise);
                    var Sji = $("#BoTa tr").length
                    $.ajax({
                        url: '/Cuobaojia/bomini',
                        type: 'POST',
                        data: JSON.stringify(BOMinise),
                        contentType: "application/json;charset=utf-8",
                        dataType: "json",
                        success: function (e) {
                            if (e == Sji) {
                                shunji = 1;
                            }
                        },
                        error: function () {
                            alert("系统有误--！");
                        }
                    })
                }
            })
        })
        //获取文件路径
        $(function () {
            $("#exampleFormControlFile1").click(function () {
                $.ajax({
                    url: '/Cuobaojia/SelectPath',
                    type: 'POST',
                    data: { "shu": 1 },
                    success: function (fgggh) {
                        $("#textfield").val(fgggh)
                    },
                    error: function () {
                        alert("系统错误");
                    }
                })
            }); $("#exampleFormControlFile2").click(function () {
                $.ajax({
                    url: '/Cuobaojia/SelectPath',
                    type: 'POST',
                    data: { "shu": 1 },
                    success: function (fgggh) {
                        $("#textfielded").val(fgggh)
                    },
                    error: function () {
                        alert("系统错误");
                    }
                })
            })
            $("#exampleFormControlFile3").click(function () {
                $.ajax({
                    url: '/Cuobaojia/SelectPath',
                    type: 'POST',
                    data: { "shu": 1 },
                    success: function (fgggh) {
                        $("#textfieldsd").val(fgggh)
                    },
                    error: function () {
                        alert("系统错误");
                    }
                })
            })
        })
        //gy隐藏显示
        $(function () {

            //表面
            $('input[name="Biaomian"]').click(function () {
                $("#Yinchangs").toggle();
            })
            //塑料
            $('input[name="Shuliao"]').click(function () {
                $("#Yinchangsed").toggle();
            })

            //点击确定按钮//表面
            $("#BiaQ").click(function () {
                $("#Yinchangs").find("input[type='checkbox']").each(function () {
                    if ($(this).prop("checked")) {
                        $('input[name="Biaomian"]').val($('input[name="Biaomian"]').val() + ($('input[name="Biaomian"]').val() == "" ? "" : ",") + $(this).val())
                        $(this).prop('checked', false)
                        $(this).prop('disabled', true)
                    }
                });
                $("#Yinchangs").hide()
            })
            $("#QingQ").click(function () {
                $("#Yinchangs").find("input[type='checkbox']").each(function () {
                    $('input[name="Biaomian"]').val('')
                    if ($(this).prop("disabled")) {
                        $(this).prop('disabled', false)
                    }
                });
            })
            //点击确定按钮//塑料
            $("#BiaQ1").click(function () {
                $("#Yinchangsed").find("input[type='checkbox']").each(function () {
                    if ($(this).prop("checked")) {
                        $('input[name="Shuliao"]').val($('input[name="Shuliao"]').val() + ($('input[name="Shuliao"]').val() == "" ? "" : ",") + $(this).val())
                        $(this).prop('checked', false)
                        $(this).prop('disabled', true)
                    }
                });
                $("#Yinchangsed").hide()
            })
            $("#QingQ1").click(function () {
                $("#Yinchangsed").find("input[type='checkbox']").each(function () {
                    $('input[name="Shuliao"]').val('')
                    if ($(this).prop("disabled")) {
                        $(this).prop('disabled', false)
                    }
                });
            })
        })
        //木制品
        $(function () {
            //计算总价
            function zhongjia() {
                var Mucai = $("#ALL_MCF").text() * 1
                var Fuliao = $("#ALL_FLF").text() * 1
                var Jiagong = $("#ALL_jgf").text() * 1
                var Yunshu = $("#MZ_YSFXJ").text() * 1
                var Renchuli = $("#RC_YSFXJ").text() * 1
                var Sunm = Mucai + Fuliao + Jiagong + Yunshu + Renchuli
                $("#Zongji").text(Sunm)
            }
            //计算辅料价格
            function accessory(e) {
                var s = e.val() * 1
                var j = e.parent().next().text() * 1
                e.parent().next().next().text(s * j)
                var sum=0
                $(".MZ_FLF").each(function (i, item) {
                    sum+=$(item).text()*1
                })
                $("#ALL_FLF").text(sum)
                zhongjia()
            }
            //计算木材体积和价格
            function Calculated_Volume(e) {
                var c = e.parent().parent().children().eq(3).children().val()
                var k = e.parent().parent().children().eq(4).children().val()
                var g = e.parent().parent().children().eq(6).children().val()
                var s = e.parent().parent().children().eq(7).children().val()
                var sh = e.parent().parent().children().eq(9).text()
                var j = e.parent().parent().children().eq(10).text()
                var m3 = c * k * g * s / 1000000000
                e.parent().parent().children().eq(8).text((m3).toFixed(4))
                e.parent().parent().children().eq(11).text(((m3 * j) * (1 + sh * 1)).toFixed(4))
                var sum = 0
                var num=0
                $(".MZ_MCF").each(function (i, item) {
                    sum += $(item).text() * 1
                })
                $("#ALL_MCF").text(sum.toFixed(6))
                $(".MZ_TJ").each(function (j, obj) {
                    num += $(obj).text() * 1
                })
                $("#ALL_MCTJ").text(num.toFixed(6))
                zhongjia()
            }
            //根据材料类别获取损耗和立方价格
            function Wear_Price_w_ZL(e) {
                var lei = e.val()
                console.log(lei)
                $.ajax({
                    url: "/Procure/woodwork",
                    type: 'GET',
                    data: { "state": 2, "miaoshu": lei },
                    success: function (data) {
                        $.each(data, function (i, item) {
                            e.parent().parent().children().eq(9).text(0.1)
                            e.parent().parent().children().eq(10).text(item.PA_T)

                        })
                        Calculated_Volume(e)
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
            }
            //新增木材费表格行
            function Add_table_row_Timber(e) {
                var caoz = e.text()
                if (caoz == "添加") {
                    e.text("删除")
                    var $tr = $(`
                                 <tr>
                                    <td></td>
                                    <td><input type="text" style="width:60px;height:25px"/></td>
                                    <td>
                                        <select class="MZ_CL" style="width:60px;height:25px" id="MZ_CL">
                                            <option>请选择材料</option>
                                            @foreach (var item in ViewBag.parice as List<parice>)
                                            {
                                                if (item.PA_Shuxing == 1)
                                                {
                                                    <option value="@item.PA_ZhongL">@item.PA_ZhongL</option>
                                                }
                                            }
                                        </select>
                                    </td>
                                    <td><input type="number" class="MZ_gg" style="width:60px;height:25px"/></td>
                                    <td><input type="number" class="MZ_gg" style="width:60px;height:25px"/></td>
                                    <td><input type="number" class="MZ_gg" style="width:60px;height:25px"/></td>
                                    <td><input type="number" class="MZ_gg" style="width:60px;height:25px"/></td>
                                    <td><input type="number" class="MZ_gg" style="width:60px;height:25px"/></td>
                                    <td class="MZ_TJ"></td>
                                    <td></td>
                                    <td></td>
                                    <td class="MZ_MCF"></td>
                                    <td><a href="#" id="MZ_CZ">添加</a></td>
                                </tr>
                             `);
                    e.parent().parent().parent().append($tr)
                    var sum = 0
                    var num = 0
                    $(".MZ_MCF").each(function (i, item) {
                        sum += $(item).text() * 1
                    })
                    $("#ALL_MCF").text(sum)
                    $(".MZ_TJ").each(function (j, obj) {
                        num += $(obj).text() * 1
                    })
                    $("#ALL_MCTJ").text(num)
                    zhongjia()
                }
                else {
                    e.parent().parent().remove()
                    var sum = 0
                    var num = 0
                    $(".MZ_MCF").each(function (i, item) {
                        sum += $(item).text() * 1
                    })
                    $("#ALL_MCF").text(sum)
                    $(".MZ_TJ").each(function (j, obj) {
                        num += $(obj).text() * 1
                    })
                    $("#ALL_MCTJ").text(num)
                    zhongjia()
                }
            }
            //新增辅件费用表格行
            function Add_table_row_accessory(e) {
                var caoz = e.text()
                if (caoz == "添加") {
                    e.text("删除")
                    var $tr = $(`
                    <tr>
                        <td></td>
                        <td>
                            <select style="width:60px;height:25px" id="MZ_FL">
                                <option>请选择材料</option>
                                @foreach (var item in ViewBag.parice as List<parice>)
                                {
                                    if (item.PA_Shuxing == 6)
                                    {
                                        <option value="@item.PA_T">@item.PA_ZhongL</option>
                                    }

                                }
                            </select>
                        </td>
                        <td><input type="number" style="width:60px;height:25px" id="MZ_FLSL"/></td>
                        <td></td>
                        <td class="MZ_FLF"></td>
                        <td><a href="#" id="MZ_FLH">添加</a></td>
                    </tr>
                             `);
                    e.parent().parent().parent().append($tr)
                    var sum = 0
                    $(".MZ_FLF").each(function (i, item) {
                        sum += $(item).text() * 1
                    })
                    $("#ALL_FLF").text(sum)
                    zhongjia()
                }
                else {
                    e.parent().parent().remove()
                    var sum = 0
                    $(".MZ_FLF").each(function (i, item) {
                        sum += $(item).text() * 1
                    })
                    $("#ALL_FLF").text(sum)
                    zhongjia()
                }
            }
            //新增加工费
            function Add_table_row_Processing(e) {
                var caoz = e.text()
                if (caoz == "添加") {
                    e.text("删除")
                    var $tr = $(`
                                <tr>
                                    <td><input type="text" style="width:60px;height:25px"/></td>
                                    <td><input type="number" class="MZ_jgf" style="width:60px;height:25px"/></td>
                                    <td><a href="#" id="MZ_JGFH">添加</a></td>
                                </tr>
                             `);
                    e.parent().parent().parent().append($tr)

                }
                else {
                    e.parent().parent().remove()
                }
            }
            //切换二级分类来触发事件
            function Search_SrocessingFee() {
                var miaoshu = $("#MZP_ms").val()
                $.ajax({
                    url: "/Procure/woodwork",
                    type: 'GET',
                    data: { "state": 1, "miaoshu": miaoshu },
                    success: function (data) {
                        $.each(data, function (i, item) {
                            $("#MZP_jgf").text(item.LB_jia)
                        })
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
            }
            //计算运输费小计
            function Transportation_charges_subtotal() {
                var num = $("#MZ_ZCSL").val()*1
                var all = $("#MZ_YSF").val() * 1
                console.log(all)
                console.log(num)
                sub=all/num
                $("#MZ_YSFXJ").text(sub.toFixed(4))
                zhongjia()
            }
            //计算总加工费
            function Processing_cost() {
                var sum=0
                $(".MZ_jgf").each(function (i, item) {
                    sum += $(item).val()*1
                })
                var rg= $("#MZ_RGF").text()*1
                $("#ALL_jgf").text(sum + rg)
                zhongjia()
            }
            $(document).on("keyup", ".MZ_jgf", function (i, item) {
                Processing_cost()
            })
            //修改加工费(木箱/托盘)
            $(document).on("change", "#MZ_RG", function (e) {
                var jia = $(e.target).val()
                var Ztj = $("#ALL_MCTJ").text()
                var jgf_tj = jia * Ztj
                $(e.target).parent().next().text(jgf_tj)
                zhongjia()
            })
            //输入运输费和装车数量
            $(document).on("keyup", ".MZ_YS", function (e) {
                Transportation_charges_subtotal()
            })
            //辅料费的添加/删除
            $(document).on("click", "#MZ_FLH", function (e) {
                Add_table_row_accessory($(e.target))
            })
            //加工费的添加/删除
            $(document).on("click", "#MZ_JGFH", function (e) {
                Add_table_row_Processing($(e.target))
            })
            //输入辅料数量
            $(document).on("keyup", "#MZ_FLSL", function (e) {
                accessory($(e.target))
            })
            //切换辅料名来切换单价
            $(document).on("change", "#MZ_FL", function (e) {
                var dj = $(e.target).val()
                var s = $(e.target).parent().next().children().val()
                $(e.target).parent().next().next().text(dj)
                $(e.target).parent().next().next().next().text(dj*s)
            })
            //输入木材规格
            $(document).on("keyup", ".MZ_gg", function (e) {
                Calculated_Volume($(e.target))
            })
            //下拉框修改木材的材料类别
            $(document).on("change", "#MZ_CL", function (e) {
                Wear_Price_w_ZL($(e.target))
            })
            //木材费的添加/删除
            $(document).on("click", "#MZ_CZ", function (e) {
                Add_table_row_Timber($(e.target))
            })
            $(document).on("click", "#MZP_ms", function (e) {
                Search_SrocessingFee()
            })
            //切换热处理名称来切换单价
            $("#Ren_chu").change(function (e) {
                var ghjkl = $(e.target).val()
                var jie = ghjkl.split('+')
                var zhunag = jie[0]//状态判断
                var Ren_jia = jie[1]//价格
                //获取规格
                var llkong = $("#MZ_C").val()
                var llkuan = $("#MZ_K").val()
                var llgao = $("#MZ_G").val()
                var J_price = 0;
                switch (zhunag) {
                    case "1":
                        J_price = llkong / 1000 * llkuan / 1000 * Ren_jia
                        break;
                    case "2":
                        J_price = llkong / 1000 * llkuan / 1000 * llgao / 1000 * Ren_jia
                        break;
                    case "3":
                        J_price = Ren_jia
                        break;
                    default:
                        break;
                }
                $("#Xinxi td:nth-child(3)").text(Ren_jia)
                $("#Xinxi td:nth-child(4)").text(llkong / 1000 * llkuan / 1000)
                $("#Xinxi td:nth-child(5)").text(llkong / 1000 * llkuan / 1000 * llgao / 1000)
                $("#RC_YSFXJ").text(J_price)
                zhongjia()
            })
            //传递到后台
            $("#Queding").click(function () {
                var Zhonsgji = $("#Zongji").text()
                $.ajax({
                    url: '/Material/Index',
                    type: 'POST',
                    data: { "Zongjsia": Zhonsgji, "BOM2_id": BOM2_ids, "state": 7 },
                    success: function (e) {
                        alert(e);
                        $("#jsmb").css("display", "none");
                    },
                    error: function () {
                        alert("系统错误");
                    }
                })
            })
        })
        //彩印计算
        //计算初始值
        function hdhfjjjd() {
            var cycs = $("#CY_xian tr td:nth-child(1)").text()//净尺寸
            var cyks = $("#CY_xian tr td:nth-child(2)").text()//门幅
            var ksnif = $("#CY_xian tr td:nth-child(3)").text()//棉织厂
            var CY_ges = $("#CY_ge").val()//模数
            var CY_dunj = $("#CY_tj").val()//吨价
            var CY_kezs = $("#CY_kez").val()//克重
            var CY_Lenz = $("#CY_Lenz").val()
            var CYjiagon = cycs / 1000 * ksnif / 1000 / CY_ges//加工面积
            //面积：cyks*ksnif/1000000/CY_ges
            var mianjigs = cyks * 1 * ksnif * 1 / 1000000 / CY_ges * 1//面纸面积
            var mianjigsed = CY_dunj / 1000 * mianjigs * CY_kezs / 1000 //面纸单价
            $("#CY_xian tr td:nth-child(5)").text(mianjigs.toFixed(5))
            $("#CY_xian tr td:nth-child(8)").text(mianjigsed.toFixed(5))
            $("#CY_xian tr td:nth-child(9)").text(CYjiagon.toFixed(5))
            $("#CY_xian tr td:nth-child(11)").text((CYjiagon * 1 * CY_Lenz * 1).toFixed(5))
            var CYzhong = mianjigsed * 1 + (CYjiagon * 1 * CY_Lenz * 1)
            $("#Zjgkgond").text(CYzhong.toFixed(5))
            hdufh()
        }
        //加工计算
        function hoinigjia() {
            var sdhfhd = $("#kokok").val()//颜色
            var sdhfhedd = $("#lolol").val()//价格
            var CY_ges = $("#CY_ge").val()//模数
            var shfhf = (sdhfhd * sdhfhedd * 1) / CY_ges
            var hhhdjjdf = $("#CY_seld").parent().next().change().text()//表面处理价格
            var sjifn = $("#CY_xian tr td:nth-child(9)").text()//加工面积
            //表面处理的总价格
            var shunfj = hhhdjjdf * sjifn
            //裱楞， 模切
            var shfidid = sjifn * 0.3
            var shfidided = sjifn * 0.3
            var shigndk = shunfj * 1 + shfidid * 1 + shfidided * 1 + shfhf * 1
            $("#CY_seld").parent().next().next().change().text(shfidid.toFixed(5))
            $("#CY_seld").parent().next().next().next().change().text(shfidided.toFixed(5))
            $("#CYst").text(shigndk.toFixed(5))
            hdufh()
        }
        //合计
        function hdufh() {
            var shunfn = $("#Zjgkgond").text()//材料总费用
            var hhdnk = $("#CYst").text()//biao
            var hding = $("#CYL_jgf").text()//fuliao
            var qodkm = $("#okkosk").text()//shuanmj
            var hdjisn = $("#CYY_jsijn").text()//baozhuangjia
            var sjihe = $("#CY_jiehea").text()
            var shunfhao = (shunfn * 1 + hhdnk * 1 + sjihe * 1) * 0.03
            $("#CY_shuan").text(shunfhao.toFixed(5))
            var shunnn = shunfn * 1 + hhdnk * 1 + hding * 1 + qodkm * 1 + hdjisn * 1 + shunfhao*1
            $("#shugnd").text(shunnn.toFixed(5))
        }
        $(function () {
            //新增辅料费
            function Add_table_row_accessory(e) {
                var caoz = e.text()
                if (caoz == "添加") {
                    e.text("删除")
                    var $tr = $(`
                                <tr>
                                    <td> <select style="width:100px;height:25px" id="CY_Gongf">
                                    <option value="">塑料提手</option>
                                    <option value="">手提绳</option>
                                    <option value="">塑料扣</option>
                                    <option value="">塑料窗</option>
                                    <option value="0.1">工费</option>
                                </select></td>
                                    <td><input type="number" class="CY_jgf" style="width:100px;height:25px"placeholder="辅料价格" min="0"/></td>
                                    <td><input type="number" class="CY_jgh" style="width:100px;height:25px" min="0" value="1"/></td>
                                    <td><a href="#" id="CY_JGFH">添加</a></td>
                                </tr>
                             `);
                    e.parent().parent().parent().append($tr)
                    Processing_cost()
                }
                else {
                    e.parent().parent().remove()
                    Processing_cost()
                }
            }
            function Add_table_ro(e) {
                var caoz = e.text()
                if (caoz == "添加") {
                    e.text("删除")
                    var $tr = $(`
                                <tr>
                                    <td>
                               <select style="width:100px;height:25px" id="CY_tingf">
                               <option value=""></option>
                                   @foreach (var item in ViewBag.Yinshua as List<libray>)
                                   {
                                       if (item.ST_ID == 1019)
                                       {
                                           <option value="@item.LB_jia">@item.LB_fne</option>
                                       }
                                   }
                               </select>
                           </td>
                           <td class="CY_tingf"></td>
                           <td><a href="#" id="CY_JGFHS">添加</a></td>
                                </tr>
                             `);
                    e.parent().parent().parent().append($tr)
                    Processing()
                }
                else {
                    e.parent().parent().remove()
                    Processing()
                }
            }
            function Processing_cost() {
                var sum = 0
                $(".CY_jgf").each(function (i, item) {
                  var shufn=  $(item).parent().next().children().val()
                    sum += $(item).val() * shufn
                })
                $("#CYL_jgf").text(sum)
                hdufh()
            }
            function Processing() {
                var shungf = $("#shufn_s").val()
                var sum = 0
                $(".CY_tingf").each(function (i, item) {
                    var shufn = $(item).text()
                    console.log(shufn)
                    sum += shungf * shufn
                })
                console.log(sum)
                $("#okkosk").text(sum.toFixed(5))
                hdufh()
            }
            $(document).on("keyup", "#CY_ge,#CY_tj,#CY_kez,#CY_Lenz", function () {
                hdhfjjjd()
            })
            //计算印刷
            $(document).on("keyup", "#kokok,#lolol", function () {
                hoinigjia()
            })
            //表面处理
            $(document).on("change", "#CY_seld", function (s) {
                var shufn = $(s.target).val()
                $(s.target).parent().next().change().text(shufn)
                hoinigjia()
            })
            //贴双面胶
            $(document).on("change", "#CY_tingf", function (e) {
                var shudf = $(e.target).val()
                $(e.target).parent().next().text(shudf)
                Processing()
            })
            $(document).on("keyup", "#shufn_s", function (e) {
                var shudf = $(e.target).val()
                $(e.target).parent().next().text(shudf)
                Processing()
            })
            $(document).on("click", "#CY_JGFHS", function (e) {
                Add_table_ro($(e.target))
            })
            //辅料
            $(document).on("click", "#CY_JGFH", function (e) {
                Add_table_row_accessory($(e.target))
            })
            $(document).on("keyup", ".CY_jgf,.CY_jgh,#CY_Gongf", function () {
                Processing_cost()
            })
            $(document).on("change", "#CY_Gongf", function (e) {
                var shudf = $(e.target).val()
                $(".CY_jgf").val(shudf)
                Processing_cost()
            })
            //结合+包装
            function dhdhss() {
                var hhsss = $("#CY_baozs").text()
                var djjdf = $("#CY_jiehea").text()
                var shfnf = djjdf * 1 + hhsss * 1
                $("#CYY_jsijn").text(shfnf)
                hdufh()
            }
            $(document).on("change", "#CY_jiehe", function (e) {
                var K = $("#CY_K").val()
                var G = $("#CY_G").val()
                var shudf = $(e.target).val()
                $(e.target).parent().next().text(shudf)
                var zhongs = (K * 1 + G * 1) / 1000 * shudf
                $("#CY_jiehea").text(zhongs)
                dhdhss()
            })
            $(document).on("change", "#CY_baoz", function (e) {
                var K = $("#CY_xian tr td:nth-child(9)").text()
                var shudf = $(e.target).val()
                $(e.target).parent().next().text(shudf)
                var zhongs = K * shudf
                $("#CY_baozs").text(zhongs.toFixed(5))
                dhdhss()
            })
        })
        //塑料制品
        $(function () {

            //计算理论净重
            function Material_weight() {
                var c = $("#SL_C").val()//长
                var k = $("#SL_K").val()//宽
                var h = $("#SL_H").val()//厚度
                var m = $("#SL_M").val()//密度
                var v = $("#sl_wlfl").val()//物料基数
                if ($("#sl_wlfl").val() == "胶带") {
                    var kg = (c / 1000) * (k / 1000) * h / 1000 * m
                    $("#SL_SJZL").val(kg)
                }
                else {
                    var kg = (c / 1000) * (k / 1000) * h * m * v
                    $("#SL_LLJZ").val(kg)
                }

            }
            //计算物料材料费
            function Calculated_size() {
                var sj = $("#SL_SJZL").val()
                var kj = $("#SL_wldj").text()
                $("#SL_CLF").text((sj * kj * 1000).toFixed(4))
                SUM_price()
            }
            //根据种类搜索加工费损耗
            function change_sl_ProcessingCost() {
                var sl_ms = $("#sl_ms").val()
                console.log(sl_ms)
                $.ajax({
                    url: "/Procure/Plastic_product",
                    type: 'GET',
                    data: { "state": 1, "miaoshu": sl_ms },
                    success: function (data) {
                        Print_plastic_composition(data)
                        Gram_value()
                        Calculated_size()
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
            }
            //打印塑料组成
            function Print_plastic_composition(data) {
                $('#SL_WLZC tr').remove();
                $.each(data, function (i, item) {
                    var $tr = $(`
                    <tr style="background-color:#E8ECF6">
                        <td>${item.PA_ZhongL}</td>
                        <td>${item.PR_dai}</td>
                        <td>${item.PA_T}</td>
                        <td class="CL_jg">${item.PA_T * item.PR_dai}</td>
                    </tr>
                `);
                    $('#SL_WLZC').append($tr);
                })
            }
            //计算物料总价
            function SUM_price() {
                var sum=0
                $(".SL_FY_t").each(function (i, item) {
                    sum+=$(item).text()*1
                })
                var num = 0
                $(".SL_FY_v").each(function (j, obj) {
                    num += $(obj).val()*1
                })
                var j_All = 0
                $(".SL_GY_jgf").each(function (x, index) {
                    j_All += $(index).text()*1
                })
                $("#SL_HJ").text(sum * 1 + num * 1 + j_All * 1)
                console.log(sum + "+" + num + "+" + j_All)

            }
            //搜索纸管价格
            function Paper_tube(e) {
                var name = e.val()
                $.ajax({
                    url: "/Procure/Plastic_product",
                    type: 'GET',
                    data: { "state": 3, "miaoshu":  name},
                    success: function (data) {
                        var k = $("#SL_K").val()//宽
                        $.each(data, function (i, item) {
                            $("#SL_ZG").text((item.PA_T * (k / 1000)).toFixed(4))
                        })
                        freight()
                        Tape_freight()
                        SUM_price()
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
            }
            //计算物料克价格
            function Gram_value() {
                var sum = 0
                $(".CL_jg").each(function (i, item) {
                    sum += $(item).text() * 1
                })
                $("#SL_wldj").text(sum / 1000000)
                $("#SL_wldj_2").text(sum / 1000000)
            }
            //计算胶带运费的方法
            function Tape_freight() {
                if ($("#sl_wlfl").val() == "胶带" && $("#inp_yunf").prop("checked")) {
                    var clf = $("#SL_CLF").text()
                    var sum = 0
                    $(".SL_JD_YF").each(function (i, item) {
                        sum += $(item).text() * 1
                    })
                    var yf = sum * 0.05
                    $("#SL_sld_yf").text((yf).toFixed(4))
                }
            }
            //搜索工艺流程
            function Process_flow(e) {
                var name = e.val()
                if (name != "缓冲材") {
                    $.ajax({
                        url: "/Procure/Plastic_product",
                        type: 'GET',
                        data: { "state": 4, "miaoshu": name },
                        success: function (data) {
                            PrintingProcessFlow(data)
                        },
                        error: function () {
                            alert('Request Error');
                        }
                    })
                }
                else {
                    $("#SL_GYSC tr").remove()
                    $('#SL_WLZC tr').remove();
                }
            }
            //打印工艺流程
            function PrintingProcessFlow(data) {
                $("#SL_GYSC tr").remove()
                $.each(data, function (i, item) {
                    var id = item.LB_ID
                    var $tr = $(`
                        <tr>
                            <th>${item.ST_fne}</th>
                            <th>
                                <select id="${item.LB_ID}" class="SL_GYLC">
                                <option value="0">请选择</option>
                                </select>
                            </th>
                            <th>加工费</th>
                            <th class="SL_GY_jgf SL_JD_YF"></th>
                        </tr>
                    `);
                    $("#SL_GYSC").append($tr)
                    $.ajax({
                        url: "/Procure/Plastic_product",
                        type: 'GET',
                        data: { "state": 5, "num": id },
                        success: function (data) {
                            $.each(data, function (i, obj) {
                                $("select[id=" + id + "]").append($(`<option value="${obj.LB_jia}">${obj.LB_fne}</option>`))
                            })

                        },
                        error: function () {
                            alert('Request Error');
                        }
                    })
                })
            }
            //修改净重计算加工费
            function Netweight_Processingfee() {
                var zl = $("#sl_wlfl").val()
                if (zl == "胶带") {
                    var c = $("#SL_C").val()//长
                    var k = $("#SL_K").val()//宽
                    var KG = (c/1000)*(k/1000)
                    $(".SL_GYLC").each(function (i, item) {
                        var jia = $(item).val()
                        $(item).parent().next().next().text((KG * jia).toFixed(4))
                    })
                }
                else if (zl == "气泡袋") {
                    var KG = $("#SL_wlzl").text()
                    $(".SL_GYLC").each(function (i, item) {
                        var jia = $(item).val()
                        $(item).parent().next().next().text(((KG/1000) * jia).toFixed(4))
                    })
                }
                else {
                    var KG = $("#SL_SJZL").val()
                    $(".SL_GYLC").each(function (i, item) {
                        var jia = $(item).val()
                        $(item).parent().next().next().text((KG * jia).toFixed(4))
                    })
                }
            }
            //修改物料克重重新计算运费
            function freight() {
                var zl = $("#sl_wlfl").val()
                var clf = $("#SL_CLF").text()
                var yf = clf * 0.02
                if (zl == "塑料袋") {
                    $("#SL_sld_yf").text((yf).toFixed(4))
                }
            }
            //修改规格算法
            function spec() {
                var zl = $("#sl_wlfl").val()
                if (zl == "胶带") {
                    $("#SL_GG tr").remove()
                    var $tr = $(`<tr>
                                    <td rowspan="2">规格</td>
                                    <td>长(mm)</td>
                                    <td><input type="number" class="inp" id="SL_C" /></td>
                                    <td>宽(mm)</td>
                                    <td><input type="number" class="inp" id="SL_K" /></td>
                                    <td>厚度(um)</td>
                                    <td><input type="number" value="50" class="inp" id="SL_H" /></td>
                                    <td>密度（g/cm³)</td>
                                    <td><input type="number" value="0.91" class="inp" id="SL_M" /></td>
                                </tr>
                                `)
                    $("#SL_GG").append($tr)
                }
                else {
                    $("#SL_GG tr").remove()
                    var $tr = $(`<tr>
                                    <td rowspan="2">规格</td>
                                    <td>长(mm)</td>
                                    <td><input type="number" class="inp" id="SL_C" /></td>
                                    <td>宽(mm)</td>
                                    <td><input type="number" class="inp" id="SL_K" /></td>
                                    <td>单层厚度(mm)</td>
                                    <td><input type="number" class="inp" id="SL_H" /></td>
                                    <td>密度（g/cm³)</td>
                                    <td><input type="number" value="0.92" class="inp" id="SL_M" /></td>
                                    <td>理论净重(KG)</td>
                                    <td><input type="number" class="inp" id="SL_LLJZ" /></td>
                                </tr>
                                `)
                    $("#SL_GG").append($tr)
                }
            }
            //切换显示
            function Switch_display() {
                var zl = $("#sl_wlfl").val()
                if (zl == "气泡袋") {
                    $("#tab1").css({ "display": "none" })
                    $("#tab2").css({ "display": "block" })
                    $("#tab3").css({ "display": "none" })
                }
                else if (zl=="缓冲材") {
                    $("#tab1").css({ "display": "none" })
                    $("#tab2").css({ "display": "none" })
                    $("#tab3").css({ "display": "block" })
                }
                else {
                    $("#tab2").css({ "display": "none" })
                    $("#tab1").css({ "display": "block" })
                    $("#tab3").css({ "display": "none" })
                }
            }
            //添加运费/纸箱价格
            $(document).on("click", ".inp_show", function (e) {
                if ($(e.target).prop("checked")) {
                    if ($(e.target).val() == "运费" && $("#sl_wlfl").val() == "塑料袋") {
                        var clf = $("#SL_CLF").text()
                        var yf = clf * 0.02
                        $(e.target).parent().next().text((yf).toFixed())
                    }
                    else if ($(e.target).val() == "运费" && $("#sl_wlfl").val() == "胶带") {
                        var sum = 0
                        $(".SL_JD_YF").each(function (i, item) {
                            sum += $(item).text() * 1
                        })
                        var yf = sum * 0.05
                        console.log(sum)
                        $("#SL_sld_yf").text((yf).toFixed(4))
                    }
                    else {
                        var $inp = $(`<input type="text" class="SL_FY_v" style="width:60px;height:30px"/>`);
                        $(e.target).parent().next().append($inp)
                    }
                }
                else {
                    if ($(e.target).val() == "运费" && $("#sl_wlfl").val() == "塑料袋") {
                        $(e.target).parent().next().text("")
                    }
                    else if ($(e.target).val() == "运费" && $("#sl_wlfl").val() == "胶带") {
                        $(e.target).parent().next().text("")
                    }
                    else {
                        $(e.target).parent().next().children().remove($inp)
                    }

                }
                SUM_price()
            })
            //切换工艺计算加工费
            $(document).on("change", ".SL_GYLC", function (e) {
                Netweight_Processingfee()
                SUM_price()

            })
            //修改物料种类
            $(document).on("change", "#sl_wlfl", function (e) {
                Process_flow($(e.target))
                Switch_display()
            })
            //添加纸管价格
            $(document).on("click", "#SL_FL_ZG", function (e) {
                if ($(e.target).prop("checked")) {
                    Paper_tube($(e.target))
                }
                else {
                    $("#SL_ZG").text(0)
                    SUM_price()
                }

            })
            //运费/纸箱输入框输入触发
            $(document).on("keyup", ".SL_FY_v", function () {
                SUM_price()

            })
            //修改物料种类
            $(document).on("change", "#sl_wlfl", function () {
                Gram_value()
                Material_weight();
                SUM_price()
                spec()
                Tape_freight()

            })
            //修改物料实际克重
            $(document).on("keyup", "#SL_SJZL", function () {
                Calculated_size()
                Netweight_Processingfee()
                SUM_price()
                freight()
                Tape_freight()
            })
            //点击切换种类
            $(document).on("change", "#sl_ms", function () {
                change_sl_ProcessingCost()
                Tape_freight()
            })
            //修改长宽事件
            $(document).on("keyup", ".inp", function () {
                Netweight_Processingfee()
                Material_weight()
                Tape_freight()
                Calculated_size()
            })
            //提交计算结果
            $("#SHULbec").click(function () {
                var HEji1 = "";
                var sel1 = $("#sl_wlfl").val();
                var sel2 = $("#HCC_ZL").val();
                console.log(sel1);
                console.log(sel2);
                //胶带  塑料袋  气泡枕  葫芦袋  气泡袋  缠绕膜
                //裁切  1 2
                if ((sel1 == "缠绕膜" || sel1 == "气泡枕" || sel1 == "葫芦袋" || sel1 == "胶带" || sel1 == "塑料袋") && sel2=="0") {
                    HEji1 = $("#SL_HJ").text()
                } else if (sel1 == "气泡袋" && sel2 == "0") {
                    HEji1 = $("#SL_HJ_2").text()
                } else if (sel1 == "缓冲材" && sel2 == "1") {
                    HEji1 = $("#ALL_CB_price").text()
                } else if (sel1 == "缓冲材" && sel2=="2") {
                    HEji1 = $("#FP_ZJG").text()
                }
                console.log(HEji1)
                console.log(BOM2_ids)
                $.ajax({
                    url: '/Material/Index',
                    type: 'POST',
                    data: { "Zongjsia": HEji1, "BOM2_id": BOM2_ids, "state": 7 },
                    success: function (e) {
                        alert(e);
                        $("#SHUliao").css("display", "none");
                    },
                    error: function () {
                        alert("系统错误");
                    }
                })
            })
        })
        //气泡袋
        $(function () {
            Calculated_size()
            Calculated_weight_SL()
            //计算物料大小
            function Calculated_size() {
                var c = $("#SL_gg_C").val()
                var k = $("#SL_gg_K").val()
                $("#SL_gg_dx").text((c * k/1000000*2).toFixed(4))
            }
            //计算加工费
            function Netweight_Processingfee() {
                var zl = $("#sl_wlfl").val()
                if (zl == "胶带") {
                    var c = $("#SL_C").val()//长
                    var k = $("#SL_K").val()//宽
                    var KG = (c / 1000) * (k / 1000)
                    $(".SL_GYLC").each(function (i, item) {
                        var jia = $(item).val()
                        $(item).parent().next().next().text((KG * jia).toFixed(4))
                    })
                }
                else if (zl == "气泡袋") {
                    var KG = $("#SL_wlzl").text()
                    $(".SL_GYLC").each(function (i, item) {
                        var jia = $(item).val()
                        $(item).parent().next().next().text(((KG / 1000) * jia).toFixed(4))
                    })
                }
                else {
                    var KG = $("#SL_SJZL").val()
                    $(".SL_GYLC").each(function (i, item) {
                        var jia = $(item).val()
                        $(item).parent().next().next().text((KG * jia).toFixed(4))
                    })
                }
            }
            //计算气泡袋运费
            function freight_qpd() {
                var m = $("#SL_gg_dx").text()
                var yf = (m * 0.1).toFixed(4)
                $("#SL_qpd_yf").text(yf)
            }
            //计算材料重量和价格
            function Calculated_weight_SL() {
                $("#SL_wlzl").text(($("#SL_gg_Z").val() * $("#SL_gg_dx").text()).toFixed(4))

                var jia = ($("#SL_wlzl").text() * $("#SL_gg_dx").text())

            }
            //计算物料价格
            function Sum_up_W_SL() {
                var sum = 0
                var yf = $("#SL_qpd_yf").text()
                var cl = $("#SL_wldj_2").text() * $("#SL_wlzl").text()
                $(".SL_GY_jgf").each(function (i, item) {
                    sum += $(item).text() * 1
                })
                var num = sum * 1 + yf * 1 + cl*1
                $("#SL_HJ_2").text(num)
            }
            //修改克重数量触发
            $(document).on("keyup", "#SL_gg_Z", function (e) {
                Calculated_weight_SL()
                Sum_up_W_SL()
            })
            //修改物料数据触发
            $(document).on("keyup", ".wl_sj", function () {
                freight_qpd()
                Netweight_Processingfee()
                Calculated_size()
                Calculated_weight_SL()
                Sum_up_W_SL()
            })
        })
        //裁切缓冲材
        $(function () {
            //切换密度查找立方价
            $(document).on("change", "#HC_MD", function (e) {
                var jia = $(e.target).val()//立方价格
                $(e.target).parent().next().text(jia)
                ALL_price()
            })
            //改变长/宽/高/数量/损耗时触发
            $(document).on("keyup", ".HC_GG", function (e) {
                Calculated_volume($(e.target))//计算体积
                price($(e.target))//计算费用
                ALL_price()
            })
            //改变密度时触发
            $(document).on("change", "#HC_MD", function (e) {
                price($(e.target))
                ALL_price()
            })
            //点击添加时触发
            $(document).on("click", "#HC_CZ", function (e) {
                Table_row($(e.target))
                ALL_price()
            })
            //添加和删除行的方法
            function Table_row(e) {
                var zt = e.text()
                console.log(zt)
                if (zt == "添加") {
                    e.text("删除")
                    var $tr = $(`
                    <tr>
                        <th><input type="number" class="HC_GG" id="HC_C" style="width:60px;height:30px" /></th>
                        <th><input type="number" class="HC_GG" id="HC_K" style="width:60px;height:30px" /></th>
                        <th><input type="number" class="HC_GG" id="HC_G" style="width:60px;height:30px" /></th>
                        <th>
                            <select id="HC_MD" style="width:60px;height:30px">
                                <option>密度</option>
                                @foreach (var item in ViewBag.parice as List<parice>)
                                {
                                    if (@item.PA_LengBie == "裁切缓冲材")
                                    {
                                        <option value="@item.PA_T">@item.PA_ZhongL</option>
                                    }

                                }
                            </select>
                        </th>
                        <th></th>
                        <th><input type="number" class="HC_GG" id="HC_SL" style="width:60px;height:30px" value="1"/></th>
                        <th class="HC_TJ_c"></th>
                        <th><input type="number" class="HC_GG" id="HC_SH" style="width:60px;height:30px" value="10"/></th>
                        <th class="HC_clf"></th>
                        <th class="HC_jgf"></th>
                        <th class="HC_cb"></th>
                        <th><a href="#" id="HC_CZ">添加</a></th>
                    </tr>
                    `)
                    $("#tab3_tbody").append($tr)
                }
                else {
                    e.parent().parent().remove()
                }
            }
            //计算价格的方法
            function price(e) {
                var jia = e.parent().parent().children().eq(4).text()//立方价
                var tj = e.parent().parent().children().eq(6).text()//体积
                var sh = e.parent().parent().children().eq(7).children().val()//损耗

                var clf = jia * tj * (1 + sh * 0.01)//材料费
                var jgf = clf * 0.5//加工费
                var cbkg = clf * 1 + jgf * 1//成本价格
                console.log(jia)
                console.log(tj)
                console.log(sh)
                e.parent().parent().children().eq(8).text((clf).toFixed(4))//材料费
                e.parent().parent().children().eq(9).text((jgf).toFixed(4))//加工费
                e.parent().parent().children().eq(10).text((cbkg).toFixed(4))//成本价格
            }
            //计算体积的方法
            function Calculated_volume(e) {
                var c = e.parent().parent().children().eq(0).children().val()//长
                var k = e.parent().parent().children().eq(1).children().val()//宽
                var g = e.parent().parent().children().eq(2).children().val()//高
                var s = e.parent().parent().children().eq(5).children().val()//数量
                var tj = c * k * g / 1000000000 * s
                e.parent().parent().children().eq(6).text((tj).toFixed(4))
            }
            //计算总价的方法
            function ALL_price() {
                var clf = 0
                var jhf = 0
                var cb = 0
                var tj=0
                $(".HC_clf").each(function (i, item) {
                    clf += $(item).text()*1
                })
                $("#ALL_CL_price").text((clf).toFixed(5))

                $(".HC_TJ_c").each(function (i, obj) {
                    tj += $(obj).text() * 1
                })
                $("#ALL_TJ").text((tj).toFixed(5))

                $(".HC_jgf").each(function (i, sum) {
                    jhf += $(sum).text() * 1
                })
                $("#ALL_JG_price").text((jhf).toFixed(5))

                $(".HC_cb").each(function (i, index) {
                    cb += $(index).text() * 1
                })
                $("#ALL_CB_price").text((cb).toFixed(5))

            }
        })
        //发泡缓冲材
        $(function () {
            //切换裁切和发泡
            $(document).on("change", "#HCC_ZL", function (e) {
                var zl = $(e.target).val()
                if (zl == 1) {
                    $("#HC_FP").css({ "display": "none" })
                    $("#HC_CQ").css({ "display": "block" })
                }
                else if (zl == 2) {
                    $("#HC_FP").css({ "display": "block" })
                    $("#HC_CQ").css({"display":"none"})
                }
                else {
                    $("#HC_FP").css({ "display": "none" })
                    $("#HC_CQ").css({ "display": "none" })
                }
            })
            //切换物料类型
            $(document).on("change", "#FP_ZL", function (e) {
                Process_flow($(e.target))
                Calculate_the_price()
            })
            //输入物料重量时触发
            $(document).on("keyup", "#FP_WLZL", function () {
                Calculate_the_price()
            })
            //搜索发泡缓冲料工艺流程
            function Process_flow(e) {
                var zl = e.val()
                $.ajax({
                    url: "/Procure/Plastic_product",
                    type: 'GET',
                    data: { "state": 6, "miaoshu": zl },
                    success: function (data) {
                        Printing_process_flow(data)
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
            }
            //打印工艺流程
            function Printing_process_flow(data) {
                $("#FP_GY_tb tr").remove()
                $.each(data, function (i, item) {
                    var id = item.LB_ID
                    var $tr = $(`
                    <tr>
                        <td>${item.RO_yao}</td>
                        <td class="FP_GYJG">${item.RO_bei}</td>
                    </tr>
                    `);
                    $("#FP_GY_tb").append($tr)

                })
            }
            //计算总价格
            function Calculate_the_price() {
                var sum = 0
                var z = $("#FP_WLZL").val()
                $(".FP_GYJG").each(function (i, item) {

                    sum += $(item).text()*1
                })
                var jia = z * sum
                $("#FP_ZJG").text((jia).toFixed(5))
            }
        })
    </script>
}